package ca.liu.scaffoldingmvctest.domain;

import java.io.Serializable;

import java.lang.StringBuilder;

import java.util.LinkedHashSet;
import java.util.Set;

import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;

import javax.xml.bind.annotation.*;

import javax.persistence.*;

/**
 */

@Entity
@NamedQueries({
		@NamedQuery(name = "findAllStUsers", query = "select myStUser from StUser myStUser"),
		@NamedQuery(name = "findStUserById", query = "select myStUser from StUser myStUser where myStUser.id = ?1"),
		@NamedQuery(name = "findStUserByPassword", query = "select myStUser from StUser myStUser where myStUser.password = ?1"),
		@NamedQuery(name = "findStUserByPasswordContaining", query = "select myStUser from StUser myStUser where myStUser.password like ?1"),
		@NamedQuery(name = "findStUserByPrimaryKey", query = "select myStUser from StUser myStUser where myStUser.id = ?1"),
		@NamedQuery(name = "findStUserByUsername", query = "select myStUser from StUser myStUser where myStUser.username = ?1"),
		@NamedQuery(name = "findStUserByUsernameContaining", query = "select myStUser from StUser myStUser where myStUser.username like ?1") })
@Table(schema = "public", name = "st_user")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(namespace = "scaffoldingmvctest/ca/liu/scaffoldingmvctest/domain", name = "StUser")
@XmlRootElement(namespace = "scaffoldingmvctest/ca/liu/scaffoldingmvctest/domain")
public class StUser implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 */

	@Column(name = "id", nullable = false)
	@Basic(fetch = FetchType.EAGER)
	@Id
	@XmlElement
	Integer id;
	/**
	 */

	@Column(name = "password")
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String password;
	/**
	 */

	@Column(name = "username")
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String username;

	/**
	 */
	@OneToMany(mappedBy = "stUser", cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)
	@XmlElement(name = "", namespace = "")
	java.util.Set<ca.liu.scaffoldingmvctest.domain.StLog> stLogs;

	/**
	 */
	public void setId(Integer id) {
		this.id = id;
	}

	/**
	 */
	public Integer getId() {
		return this.id;
	}

	/**
	 */
	public void setPassword(String password) {
		this.password = password;
	}

	/**
	 */
	public String getPassword() {
		return this.password;
	}

	/**
	 */
	public void setUsername(String username) {
		this.username = username;
	}

	/**
	 */
	public String getUsername() {
		return this.username;
	}

	/**
	 */
	public void setStLogs(Set<StLog> stLogs) {
		this.stLogs = stLogs;
	}

	/**
	 */
	public Set<StLog> getStLogs() {
		if (stLogs == null) {
			stLogs = new java.util.LinkedHashSet<ca.liu.scaffoldingmvctest.domain.StLog>();
		}
		return stLogs;
	}

	/**
	 */
	public StUser() {
	}

	/**
	 * Copies the contents of the specified bean into this bean.
	 *
	 */
	public void copy(StUser that) {
		setId(that.getId());
		setPassword(that.getPassword());
		setUsername(that.getUsername());
		setStLogs(new java.util.LinkedHashSet<ca.liu.scaffoldingmvctest.domain.StLog>(that.getStLogs()));
	}

	/**
	 * Returns a textual representation of a bean.
	 *
	 */
	public String toString() {

		StringBuilder buffer = new StringBuilder();

		buffer.append("id=[").append(id).append("] ");
		buffer.append("password=[").append(password).append("] ");
		buffer.append("username=[").append(username).append("] ");

		return buffer.toString();
	}

	/**
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = (int) (prime * result + ((id == null) ? 0 : id.hashCode()));
		return result;
	}

	/**
	 */
	public boolean equals(Object obj) {
		if (obj == this)
			return true;
		if (!(obj instanceof StUser))
			return false;
		StUser equalCheck = (StUser) obj;
		if ((id == null && equalCheck.id != null) || (id != null && equalCheck.id == null))
			return false;
		if (id != null && !id.equals(equalCheck.id))
			return false;
		return true;
	}
}
